package com.xxx.ware.ware_manage_sys.bean.event;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class EventProducter {

    @Autowired
    private KafkaTemplate kafkaTemplate;

    public void sendKafkaMsg(Event event){
        log.info("发送Kafka，消息：{}", event);
        kafkaTemplate.send(event.getTopic(), JSON.toJSONString(event));
    }
}
